package day26_26;

/**
 * @ClassName Solution
 * @Description TODO
 * @Author clockTown
 * @Date 2021/6/4 20:00
 * @Version 1.0
 */
public class Solution1 {
    public static int removeDuplicates(int[] nums) {
        //判断特例
        if (nums == null || nums.length == 0) {
            return 0;
        }

        if (nums.length == 1) {
            return 1;
        }

        int idx = 0;

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != nums[idx]){
                nums[++idx] = nums[i];
            }
        }

        return idx + 1;
    }

    public static void main(String[] args) {
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(nums));
    }
}
